package com.exartisan.utils.file;

import java.io.BufferedReader;
import java.io.InputStreamReader;

import android.content.Context;

/**
 * The Class XmlUtil.
 * @author anh
 */
public class XmlUtil {

	/**
	 * Instantiates a new object.
	 */
	public XmlUtil() {
		
	}
	
	/**
	 * Read XML file from assets.
	 *
	 * @param context the context
	 * @param fileName the file name
	 * @return the content of file as string
	 */
	public static String readFromAssets(Context context, String fileName){
		StringBuilder data = new StringBuilder();
		String mLine;
		try {
			BufferedReader reader = new BufferedReader(new InputStreamReader(
					context.getAssets().open(fileName)));
			while ((mLine = reader.readLine()) != null) {
				data.append(mLine);
				data.append("\n");
			}
			reader.close();
			return data.toString();
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		}
	}

}
